import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router,{loadRoute} from './router'
import {getUserInfo} from "@/apis/global";
import {useUserStore} from "@/stores/user";
import 'echarts';

import './assets/main.less'

const app = createApp(App)


app.use(createPinia())
app.use(router)

app.mount('#app');

(async function (){
    const {data} = await getUserInfo();
    const userStore = useUserStore()
    userStore.setUserInfo(data);

// 如果是首页，则跳转到目标页面
    const check = await loadRoute();
    router.replace(location.pathname==='/' ? {name:check} : location.pathname)
})();
